import time

lendinformation = []
dict_information = {}
class Students_admin_information():

    def __init__(self,admins = []):
        self.admins = admins

    def add_admins(self,jobid,name,age,pay):
        ad_information = {'jobid':jobid,'name':name,'age':age,'pay':pay}
        self.admins.append(ad_information)

    def find_admins(self,jobid):
        for self.ad_information in self.admins:
            if self.ad_information.get('jobid') == jobid:
                return self.ad_information
        return None

    def del_admins(self,jobid):
        res = self.find_admins(jobid)
        if res:
            self.admins.remove(res)
        else:
            print('无此管理人员信息!')

    def change_admins(self,jobid):
        res = self.find_admins(jobid)
        if res:
            print(res)
            change_jobid = input('请输入修改后的工号:')
            change_name = input('请输入修改后的姓名:')
            change_age = input('请输入修改后的年龄:')
            change_pay = input('请输入工资:')
            res['jobid'] = change_jobid
            res['name'] = change_name
            res['age'] = change_age
            res['pay'] = change_pay
        else:
            print('无此在职人员!')

    def show_ad_informamtion(self):
        print('Wlcome to admin_information\'s system \n')
        print('=' * 50)
        print()
        print('1.查询管理人员'.center(50))
        print('2.添加人员'.center(50))
        print('3.修改人员信息'.center(50))
        print('4.删除人员信息'.center(50))
        print('5.退出系统'.center(50))
        print('6.查询所有信息'.center(50))
        print('=' * 50)

    def main(self):
        self.show_ad_informamtion()
        while 1:
            a = input('请输入指令:')
            if a == '1':
                print('您正在使用查询功能 -__- ')
                jobid = input('请输入工号:')
                jobid = int(jobid)
                print(self.find_admins(jobid))

            elif a == '2':
                jobid = input('请输入添加的工号:')
                jobid = int(jobid)
                name = input('请输入添加的管理员姓名:')
                age = input('请输入其年龄:')
                pay = input('请输入薪资:')
                self.add_admins(jobid,name,age,pay)
                print(' 添加操作成功! ')

            elif a == '3':
                jobid = input('请输入要修改的工号')
                jobid = int(jobid)
                self.change_admins(jobid)
                print(' 修改操作成功 !')

            elif a == '4':
                jobid = input('请输入要删除的工号')
                jobid = int(jobid)
                self.del_admins(jobid)
                print(' 删除操作成功 !')

            elif a == '5':
                break

            elif a == '6':
                print(self.admins)

class Job(Students_admin_information):

    bookname = ['浮生六记','活着','雪落香杉树','人间失格']
    personage_understanding1 = ['是部自传体散文,描述了作者和妻子陈芸情投意合，想要过一种布衣蔬食而从事艺术的生活，由于封建礼教的压迫与贫困生活的煎熬，终至理想破灭,是一部水平极高影响颇大的自传体随笔，在清代笔记体文学中占有相当重要的位置。该书的特点在于真纯率真，独抒性灵，不拘格套，富有创造性。']
    personage_understanding1.append('作者余华,阐述了活着究竟是什么.读了此书,通过余华明白了最简单的道理:除了生死,别无大事')
    personage_understanding1.append('以谋杀案的提审过程为主线,交织展现了种族歧视,情感与道德选择,爱与宽恕等主题,细腻而深刻')
    personage_understanding1.append('又名为丧失为人的资格')

    books = dict(zip(bookname,personage_understanding1))

    def isleapyear(self,year):
        return year%400==0 or (year % 100!=0 and year%4 ==0)

    def havedays(self,year,month):
        list31 = [1, 3, 5, 7, 8, 10, 12]
        list30 = [4, 6, 9, 11]
        if month in list31:
            return 31
        elif month in list30:
            return 30
        elif month == 2:
            if self.isleapyear(year):
                return 29
            else:
                return 28
        else:
            return 0



    def __call__(self,Everyjob):
        print(''' {}:           
        Clear 卫生
        Record book
        Record lend book
        Record lend date
        Record return date
        '''.format(Everyjob))


    def chat_explain(self):
        lendnumber = input('请问您要借几本书 ?')
        lendnumber = int(lendnumber)
        while lendnumber > 0:
            a = input('请把你将要借的书籍拿过来:')
            print(Job.books[a])
            lendnumber = int(lendnumber)
            lendinformation.append(a)
            lendnumber -= 1
        return lendinformation

    def recordlend(self):
        b = input('您确定要借么\n确定Yes不借No?')
        if b == 'Yes':
            stime1 = time.localtime()
            stime2 = time.strftime('%Y -%m -%d', stime1)
            # print(time.strftime('%Y', stime1))
            # print(time.strftime('%m', stime1))
            # print(time.strftime('%d', stime1))
            return '{}:借出书籍'.format(stime2)
        return '走好，欢迎下次光临！'

    def recordreturn(self):
        day = input('最多借30天您借几天?')
        day = int(day)
        stime1 = time.localtime()
        stime_year = time.strftime('%Y',stime1)
        stime_year = int(stime_year)
        stime_month = time.strftime('%m',stime1)
        stime_month = int(stime_month)  # 6
        stime_day = time.strftime('%d',stime1)
        stime_day = int(stime_day)     # 25

        res = self.havedays(stime_year, stime_month)    #30
        day1 = stime_day+day
        if day1 > res:
            stime_month = stime_month+1
            stime_day = day1-res

            res = '应{}-{}返回书籍'.format(stime_month,stime_day)
            return res

# s = Job()
# s('每天的工作')

class Students():
    def __init__(self,students = []):
        self.students = students

    def add(self,name,age,bookname,lenddate,returndate):
        student = {'name':name,'age':age,'bookname':bookname,'lenddate':lenddate,'returndate':returndate}
        self.students.append(student)

    @classmethod
    def lendbook(self):
        print('借书')


    @classmethod
    def returnbook(self):
        print('还书')

def main_show():
    while 1:
        a = input('请输入行为指令:')
        if a == '借书':
            print(Job.bookname)
            ad1 = Job()
            lendname = ad1.chat_explain()
            lenddate = ad1.recordlend()
            returndate = ad1.recordreturn()
            print('请将书交给管理员并进行信息登记')
            register_sid = input('请输入学号:')
            register_name = input('请输入姓名:')
            register_age = input('请输入年龄:')
            # information = 'lendbookname:{},name:{},age:{},lenddate:{},returndate:{}'.format(lendname,register_name,register_age,lenddate,returndate)
            s1 = Students()
            s1.add(register_name,register_age,lendname,lenddate,returndate)
            dict_information[register_sid] = s1.students
            print(dict_information)

Student_book = type('Student_book',(object,),{'name':'student','fun1':main_show()})
s = Student_book()
s.fun1()
# s = Students()
# s.main()